home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 45.2 KB | 1,196 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: WorldReady.Lib
- #
- # Contains: The library contains task specific to testing international
- # (including localized) script systems.
- #
- # Written by: KTA
- #
- # Copyright: © 1993-1996 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # <1.0.9> 8/15/96 MDF Left string number 6 in STR# ID 203 blank (which is equivalent
- # to 'undefined'). This way when the ApplicationResourceBase
- # variable is set to 200 (for 'US' language), CheckYesNo() in
- # UserInterface.Lib will do the appropriate unification [button
- # t:Don?t Save].
- # <1.0.8> 5/3/96 MDF InitINTLGlobals() - Added gSwitchToUSHook task reference to
- # support Intl requirements when sending strings which contain
- # precomposed doublebyte characters.
- # <1.0.7> 5/1/96 MDF Created SwitchScriptTo() and TypeKorean String() tasks. Modified
- # INitIntleGlobals(), IntlStandardFileHooks(),
- # StringsToSelectScript(), IsScriptInstalled(), SwitchScript(),
- # SwitchScriptToUS(), TypeEnglishText(), HandleDoubleByteString(),
- # TypeJapaneseString(), TypeSimplifiedChineseString(),
- # TypeTradChineseString() and RemoveTypeStrOverRide() tasks. All
- # changes per Intl request.
- # <1.0.6> 1/8/96 ML added BuildListFromResource
- # <1.0.5> 1/2/96 ML InitINTLGlobals - initialize dialog button globals
- # <1.0.4> 11/21/95 ML Add global gInfoString to InitINTLGlobals()
- # <1.0.3> 1/19/95 KTA Changed the name of ExceptionHandler() to ExceptionDispatcher().
- # <1.0.2> 12/6/94 ML Added Exception Handling support
- # <1.0.1> 4/27/94 ML InitINTLGlobals()-revised printlns
- # <2.0.8> 3/23/94 KTA/JW SetUpIntlGlobals() - Fixed problem when passing
- # in pAppLanguage that is not in pDefinedAppLanguages.
- # <2.0.7> 1/18/94 KTA Insure that SaveAs() saved the document before altering the original.
- # <2.0.6> 1/12/94 KTA Expanded TestRealDocument().
- # <2.0.5> 1/12/94 KTA Added TestRealDocument().
- # <2.0.4> 1/11/94 KTA HandleDoubleByteStrings() - Insure that the primary script is
- # the primary script.
- # <2.0.3> 1/11/94 KTA Added UserInterFace.Lib to dependancies.
- # <2.0.2> 1/11/94 KTA Handle the typing of double byte characters more gracefully.
- # <1.0.10> 12/2/93 KTA InitINTLGlobals() nows utilizes hooks in launchTwitch so all
- # launching will occur in English then switch back to original
- # script.
- # <1.0.9> 12/1/93 Lupe Added the font Phayao to the Thai font list
- # <1.0.8> 11/17/93 KTA Added some changes to support performance
- # <1.0.7> 11/12/93 KTA SetUpIntlGlobals() - FontandTextLanguage wasn't being assigned properly
- # <1.0.6> 11/11/93 KTA Added task TypeEnglishText().
- # <1.0.5> 11/11/93 KTA Support a different language system for gTextStr and gFontList
- # <1.0.4> 11/9/93 Lupe In WhichScript now checks for 'U.S.' menuItem instead of 'US'
- # <1.0.2> 11/4/93 KTA Took out a couple of printlns and updated SwitchScriptUS() and
- # SwitchScriptToOrig()
- # <1.0.1> 11/04/93 KTA Added several tasks and changed the way the globals work
- # <1.0.0> 10/27/93 KTA Created
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "Output.Lib", "UserInterface.Lib", "ExceptionHandling.Lib";
-
- #########################################################################
- # InitINTLGlobals()
- #========================================================================
- # Author: KTA
- # Description: Redefines several global varibles based on resources that are set
- # up for specific language systems.
- # Parameters: None
- # Returns: Nothing
- # Example: InitINTLGlobals();
- #========================================================================
- # History:
- # KTA 4/21/92 Created
- # ML 4/27/94 revised printlns
- # ML 11/16/95 add global for "info" string
- # ML 1/1/96 get app resource base, define button strings
- # MDF 04/30/96 Removed gLaunchTwitchHook4, and changed task refs for
- # gSetupDoText and gClearDoText to gDoTextTypeStrHook1 and
- # gDoTextTyperStrHook2, respectively, as per Intl reqs.
- # MDF 05/03/96 Added gSwitchToUSHook task reference to support Intl
- # requirements when sending strings which contain
- # precomposed doublebyte characters.
- #########################################################################
- TASK InitINTLGlobals(pAppLanguage := '', pScriptSystem := {}, pDefinedAppLanguages := {})
- begin
- WhichLanguages := WhichLanguageResources(pAppLanguage, pScriptSystem, pDefinedAppLanguages);
-
- # Define the base resource for the library
- ApplicationResourceBase := WhatResourceBase(WhichLanguages[1]);
- LibraryResourceBase := WhatResourceBase(WhichLanguages[2]);
- FontandTextResourceBase := WhatResourceBase(WhichLanguages[3]);
-
- println "This is the application language - ", WhichLanguages[1];
- println "This is the script system - ", WhichLanguages[2];
- println "This is the font and text language - ", WhichLanguages[3];
-
- if (ApplicationResourceBase)
- begin
- global gYesString := GetIndString(ApplicationResourceBase+3, 1); # "Yes", Yes/No/Cancel dialog.
- global gOKString := GetIndString(ApplicationResourceBase+3, 2); # "OK", OK/Cancel dialog
- global gSaveString := GetIndString(ApplicationResourceBase+3, 3); # "Save", Save/Don't Save/Cancel dialog.
- global gCancelString := GetIndString(ApplicationResourceBase+3, 4); # "Cancel", OK/Cancel dialog
- global gNoString := GetIndString(ApplicationResourceBase+3, 5); # "No", Yes/No/Cancel dialog.
- global gDontSaveString := GetIndString(ApplicationResourceBase+3, 6); # "Don't Save", Save/Don't Save/Cancel dialog.
- global gQuitString := GetIndString(ApplicationResourceBase+3, 7); # "Quit", Quit/Cancel dialog.
-
- global gRevertString := GetIndString(ApplicationResourceBase+3, 8); # "Revert", menu item of File menu.
- end;
-
- if(LibraryResourceBase)
- begin
-
- global gScrapTitle := GetIndString(LibraryResourceBase, 2);
- global gChooserTitle := GetIndString(LibraryResourceBase, 3);
- global gGetInfoString := GetIndString(LibraryResourceBase, 4);
-
- IntlStandardFileHooks(); # Initialize the standardFileHooks
-
- global gLaunchTwitchHook3 := task SwitchScriptToUS;
-
- ###################################################################
- # These library globals are for Fonts and the TextStr and can be passed in
- # as the third element to pScriptSystem otherwise they will default to the
- # language of the primary Script system.
- ###################################################################
- global gFontList := BuildListFromResourceINTL(FontandTextResourceBase+1); # Base+1
- global gTextStr := GetIndString(FontandTextResourceBase+2, 1); # first element of Base+2
-
- ## Handle the typing of double byte characters more gracefully
- ## This is only being done in DoText() since it generates its own strings based on font selections
- global gDoTextTypeStrHook1 := task HandleDoubleByteStrings;
- global gDoTextTypeStrHook2 := task RemoveTypeStrOverRide;
- global gSwitchToUSHook := task SwitchScriptToUS;
- end;
- else
- println "Couldn't initialize INTL globals because the pLibraryResourceBase is not defined";
- end; # InitINTLGlobals()
-
- #########################################################################
- # WhichLanguageResources( pAppLanguage, pScriptSystem, pDefinedAppLanguages )
- #========================================================================
- # Author: KTA
- # Description: Sets up globals required to swap resources for different language systems.
- # Parameters: pAppLanguage := Language of the application to be tested (should be
- # language identifier see below)
- # pScriptSystem := List of 2 elements
- # 1st element - Language of the script system (language identifier)
- # 2nd element - Boolean indicating whether script system is
- # localized or not.
- # 3rd element - Language Identifier for the language for the
- # gFontList and gTextStr. This is an optional paramter,
- # if it does not exist these will default to the language
- # of the primary script system
- # pDefinedAppLanguages - list of defined languages for the script
- # Returns: nothing - but it sets up several globals
- # Example: WhichLanguageResources('AB',{'AB',0} );
- # Notes: Language Identifier
- # US - US
- # JP - Japanese
- # SC - Simplified Chinese
- # TC - Traditional Chinese
- # KH - Korean
- # AB - Arabic
- # HB - Hebrew
- # TH - Thai
- # Global gLanguageSettings is defined as follows:
- # {
- # Application Language - (e.g. 'US')
- # {
- # Primary Script Language (e.g. 'JP'),
- # Is Primary Script Localized (i.e. 0 - NO, 1 - Yes),
- # Language for Fonts and TextStr (e.g. 'JP')
- # }
- # }
- # For example:
- # gLanguageSettings := {'US',{'JP',0,'JP'}};
- #========================================================================
- # History:
- # KTA 11/1/93 Created
- # KTA 11/11/93 Support passing in a differnet language identifier for
- # gFontList and gTextStr (it is the 3rd element of the script
- # parameter pScriptSystem)
- # KTA 11/17/93 created global gWhichLanguages
- # KTA/JW 3/23/94 Fixed problem when passing in pAppLanguage that is not
- # in pDefinedAppLanguages.
- #########################################################################
- TASK WhichLanguageResources(pAppLanguage := '', pScriptSystem := {}, pDefinedAppLanguages := {})
- begin
- ##### Determine App Language
- if (pDefinedAppLanguages)
- begin
- thePrimaryScript := PrimaryScript(); # Figure out what the Primary Script is
- if not(pAppLanguage)
- pAppLanguage := thePrimaryScript; # set the app language to the primary script
-
- if not(isMember(pAppLanguage,pDefinedAppLanguages)) # insure that resources have been defined for the AppLanguage requested.
- begin
- LogStr("Sorry, {pAppLanguage} is not contained within the list gDefinedAppLanguages");
- pAppLanguage := pDefinedAppLanguages[1]; # Set it to the first element of pDefinedAppLanguages
- end;
-
- if(pAppLanguage) # Set the script Resource Base
- Global gScriptResourceBase := WhatResourceBase(pAppLanguage);
- end;
- else
- begin
- LogStr("WARNING: the list pDefinedAppLanguages has not been defined");
- exit;
- end;
-
-
- ##### Determine System Language
- if not (pScriptSystem)
- begin
- if not(pScriptSystem)
- begin # is the Primary Script localized
- if(_matchBoolean([menuitem t:"Chooser" m:[menu o:1]]!)) # If Chooser menuItem exists then it must not be localized
- pScriptSystem := {thePrimaryScript,0};
- else
- pScriptSystem := {thePrimaryScript,1}; # if file menu does not exist then it must be
- end;
- end;
-
- if(TypeOf(pScriptSystem) = 'list')
- begin
- isLocalized := pScriptSystem[2];
- if (card(pScriptSystem) = 3) # Did they specify a language for the Fonts and TextStr??
- FontandTextLanguage := pScriptSystem[3];
- else
- FontandTextLanguage := thePrimaryScript; # Default is to use primary script language ID
-
- global gLanguageSettings := {pAppLanguage,{pScriptSystem[1],pScriptSystem[2]},FontandTextLanguage};
- pScriptSystem := pScriptSystem[1];
- if(isLocalized = 0)
- pScriptSystem := 'US'; # Not localized
- end;
- else
- LogStr("Sorry, the pScriptSystem has not been defined correct - it is not a list");
-
- return({pAppLanguage, pScriptSystem,FontandTextLanguage});
- end; # WhichLanguageResources()
-
- #########################################################################
- # IntlStandardFileHooks()
- #========================================================================
- # Author: KTA
- # Description: Set up defaults for always manipulating StandardFile in US then
- # switching back to original script
- # Parameters: None
- # Returns: nothing - but it defines several global hooks
- # Example: IntlStandardFileHooks();
- #
- #========================================================================
- # History:
- # KTA 11/1/93 Created
- # MDF 04/30/96 Removed SwitchScriptBackToOrig (for gSaveAsHook3 and
- # gOpenFileHook2) as it should always be the "U.S."
- # script, per Intl reqs.
- #########################################################################
- task IntlStandardFileHooks()
- begin
- global gSaveAsHook1 := task SwitchScriptToUS;
- global gOpenFileHook1 := task SwitchScriptToUS;
- end;
-
- #########################################################################
- # MenuTitle( menuItemOrd, MenuOrd, Hmenu )
- #========================================================================
- # Author: KTA
- # Description: Returns the title of the menuitem specified by the parameters
- # in ordinality.
- # Parameters: menuItemOrd - (integer) ordinality of menuItem
- # MenuOrd - (integer) ordinality of menu (if its hierarchical
- # this is the second level menu).
- # Hmenu - (integer) ordinality of menu ( only defined if it
- # the menuitem is a hierarchical. This is the top most
- # menu.
- # Returns: {theMITitle,theMenuHTitle, theMenuTitle};
- # Example: MenuTitle(2,3,4);
- #========================================================================
- # History:
- # KTA 4/21/92 Created
- # ML 11/29/94 Added Exception Handling support
- #########################################################################
- TASK MenuTitle(menuItemOrd, MenuOrd, Hmenu := 0)
- begin
- If not (hMenu)
- Begin
- try match[menuItem o:menuItemOrd t:?theMITitle m:[menu o:MenuOrd t:?theMenuTitle]];
- catch theError
- ExceptionDispatcher(theError);
- print "menuItem - '", theMITitle,"'";
- println " / menu - '", theMenuTitle,"'";
- returnVal := {theMITitle,theMenuTitle};
- end;
- else
- begin
- try match[menuItem o:menuItemOrd t:?theMITitle m:[menuitem o:MenuOrd t:?theMenuHTitle m:[menu o:Hmenu t:?theMenuTitle]]];
- catch theError
- ExceptionDispatcher(theError);
-
- print "menuItem - '", theMITitle,"'";
- print " / hierMenu - '", theMenuHTitle,"'";
- println " / menu - '", theMenuTitle,"'";
- returnVal := {theMITitle,theMenuHTitle, theMenuTitle};
- end;
- return(returnVal);
- end;
-
- #########################################################################
- # WhichScript( scriptTitle )
- #========================================================================
- # Author: KTA
- # Description: Returns the current and primary scripts installed
- # Parameters: scriptTitle := Requested script - Will select the script <ScriptTitle>
- # if it is installed
- # Returns: {currentScript,primaryScript} - if successful
- # 0 - if failure
- # Example: WhichScript('Arabic');
- #========================================================================
- # History:
- # KTA 4/21/92 Created
- # ML 11/29/94 Added Exception Handling support
- #########################################################################
- TASK WhichScript(scriptTitle := '')
- begin
- returnVal := 0;
- #match[application t:?CurrApp];
- #if not(CurrApp = 'Finder')
- #Select [menuitem t:'Finder'];
- if (_matchBoolean ([menuItem t:'U.S.']))
- begin
- try begin
- match [menuItem t:'U.S.' m:[menu o:?ScriptMenu]];
- match [menuItem t:?currentScript c:'' e:true m:[menu o:ScriptMenu]]!;
- println "The current script is - ", currentScript;
- match [menuItem t:?primaryScript o:3 e:true m:[menu o:ScriptMenu]]!;
- println "The primary script is - ", primaryScript;
- returnVal := {currentScript,primaryScript};
- if (scriptTitle = 'All')
- begin
- allScriptList := {};
- allScripts := _collect([menuItem m:[menu o:ScriptMenu]]!,1);
- for i := 3 to Card(allScripts)
- begin
- CurrentScript := allScripts[i];
- allScriptList := insert(currentScript.t, Card(allScriptList)+1,allScriptList);
- returnVal := allScriptList;
- end;
- end;
- else if (scriptTitle) and (scriptTitle <> currentScript)
- begin
- theScript := match[menuitem t:scriptTitle m:[menu o:ScriptMenu]]!;
- if(theScript)
- begin
- if (theScript.e)
- begin
- _select (theScript);
- Println "Selected the script - '", scriptTitle,"', it is now the current script";
- returnVal := {scriptTitle,primaryScript};
- end;
- else
- Println "!@#$% Sorry, the requested script, '", scriptTitle,"' is not enabled to select";
- end;
- else
- Println "!@#$% There was no script - '", scriptTitle,"' to select";
- end;
- end; # try
- catch theError
- ExceptionDispatcher(theError);
- end; # if (_matchBoolean ([menuItem t:'U.S.']))
- else
- println "There are no scripts installed";
-
- return(returnVal);
- end;
-
-
- #########################################################################
- # CurrentlySelectedScript()
- #========================================================================
- # Author: KTA
- # Description: Returns the language identifier for the currently selected script
- # system (see below for language identifiers.)
- # Parameters: none
- # Returns: 0 - if failure
- # language identifier of selected script - if successful
- # RM - Roman
- # JP - Japanese
- # SC - Simplified Chinese
- # TC - Traditional Chinese
- # KH - Korean
- # AB - Arabic
- # HB - Hebrew
- # TH - Thai
- # Example: CurrentlySelectedScript();
- #========================================================================
- # History:
- # KTA 11/3/93 Created
- # ML 11/29/94 Added Exception Handling support
- #########################################################################
- TASK CurrentlySelectedScript()
- begin
- returnVal := 0;
- try match[keyboard s:?CurrentScriptCode];
- catch theError
- ExceptionDispatcher(theError);
- if (CurrentScriptCode = 0)
- returnVal := "US"; # Roman (This really shouldn't be US it should be RM)
- else if (CurrentScriptCode = 1)
- returnVal := "JP"; # Japanese
- else if (CurrentScriptCode = 2)
- returnVal := "TC"; # Traditional Chinese
- else if (CurrentScriptCode = 3)
- returnVal := "KH"; # Korean
- else if (CurrentScriptCode = 4)
- returnVal := "AB"; # Arabic
- else if (CurrentScriptCode = 5)
- returnVal := "HB"; # Hebrew
- else if (CurrentScriptCode = 21)
- returnVal := "TH"; # Thai
- else if (CurrentScriptCode = 25)
- returnVal := "SC"; # Simplified Chinese
-
- return (returnVal);
- end;
-
- #########################################################################
- # PrimaryScript()
- #========================================================================
- # Author: KTA
- # Description: Returns the language identifier for the primary script
- # system (see below for language identifiers.)
- # Parameters: none
- # Returns: 0 - if failure
- # language identifier of selected script - if successful
- # RM - Roman
- # JP - Japanese
- # SC - Simplified Chinese
- # TC - Traditional Chinese
- # KH - Korean
- # AB - Arabic
- # HB - Hebrew
- # TH - Thai
- # Example: PrimaryScript();
- #========================================================================
- # History:
- # KTA 11/3/93 Created
- # ML 11/29/94 Added Exception Handling support
- #########################################################################
- TASK PrimaryScript()
- begin
- returnVal := 0;
- try match[system s:?PrimaryScriptCode];
- catch theError
- ExceptionDispatcher(theError);
- if (PrimaryScriptCode = 0)
- returnVal := "US"; # Roman (This really shouldn't be US it should be RM)
- else if (PrimaryScriptCode = 1)
- returnVal := "JP"; # Japanese
- else if (PrimaryScriptCode = 2)
- returnVal := "TC"; # Traditional Chinese
- else if (PrimaryScriptCode = 3)
- returnVal := "KH"; # Korean
- else if (PrimaryScriptCode = 4)
- returnVal := "AB"; # Arabic
- else if (PrimaryScriptCode = 5)
- returnVal := "HB"; # Hebrew
- else if (PrimaryScriptCode = 21)
- returnVal := "TH"; # Thai
- else if (PrimaryScriptCode = 25)
- returnVal := "SC"; # Simplified Chinese
-
- return (returnVal);
- end;
-
- #########################################################################
- # WhichMenuIsKeyBoardMenu(pKeyBoardMenuString)
- #========================================================================
- # Author: KTA
- # Description: Returns the ordinality of the KeyBoard menu.
- # Parameters: pKeyBoardMenuString := String 'About KeyBoards'
- # ( This could be different if system is localized)
- # Returns: ordinality of the KeyBoard menu - if successful
- # 0 - if failure
- # Example: WhichMenuIsKeyBoardMenu('About Keyboards…');
- #========================================================================
- # History:
- # KTA 11/03/93 Created
- # ML 11/29/94 Added Exception Handling support
- #########################################################################
- TASK WhichMenuIsKeyBoardMenu(pKeyBoardMenuString := 'About Keyboards…')
- begin
- returnVal := 0;
- if (_matchBoolean ([menuItem t:pKeyBoardMenuString]!))
- begin
- try match[menuItem t:pKeyBoardMenuString m:[menu o:?menuOrd]]!;
- catch theError
- ExceptionDispatcher(theError);
- returnVal := menuOrd;
- end;
- else if(_matchBoolean([menuItem t:'U.S.']!))
- begin
- try match[menuItem t:'U.S.' m:[menu o:?menuOrd]]!;
- catch theError
- ExceptionDispatcher(theError);
- returnVal := menuOrd;
- end;
- #println "This is the ReturnVal - ",returnVal;
- return(returnVal);
- end;
-
- #########################################################################
- # StringsToSelectScript( pLanguageCode )
- #========================================================================
- # Author: KTA
- # Description: Returns the a list which contains all of the strings for
- # the script so you can select it from the keyBoards menu.
- # Parameters: pLanguageCode := Two letter language identifier (see below)
- # US - U.S.
- # JP - Japanese
- # SC - Simplified Chinese
- # TC - Traditional Chinese
- # KH - Korean
- # AB - Arabic
- # HB - Hebrew
- # TH - Thai
- # Returns: 0 - if failure
- # List containing strings that are actually in the Keyboard menu
- # for that language. - if successful#
- # Example: StringsToSelectScript('AB');
- #========================================================================
- # History:
- # KTA 11/03/91 Created
- # MDF 04/30/96 Modified Traditional Chinese input method names, as per
- # Intl reqs.
- #########################################################################
- TASK StringsToSelectScript(pLanguageCode := '')
- begin
- returnVal := 0;
- if(pLanguageCode)
- begin
- if(pLanguageCode = 'US')
- returnVal := {'U.S.','U.S. - System 6'}; # US
- else if(pLanguageCode = 'JP')
- returnVal := {'DZÇΔǶÇ˲'}; # Japanese
- else if(pLanguageCode = 'TC')
- returnVal := {'¡c≈ȧ§§Â', '∫~≠µ'}; # Traditional Chinese
- else if(pLanguageCode = 'KH')
- returnVal := {'«—±€ ¿‘∑¬±‚', 'Δƒøˆ ¿‘∑¬±‚'}; # Korean
- else if(pLanguageCode = 'AB')
- returnVal := {'Ÿ—»Í', 'Ÿ—»Í†Û«Ë—†»Ë„'}; # Arabic
- else if(pLanguageCode = 'HB')
- returnVal := {'Hebrew','Ú·¯È˙†ÏÓÁ˘·†È˘‡'}; # Hebrew
- else if(pLanguageCode = 'TH')
- returnVal := {'Thai', 'Thai-DTP', 'Thai-PattaChote'}; # Thai
- else if(pLanguageCode = 'SC')
- returnVal := {' ‰»Î∑Ω∑®'}; # Simplified Chinese
- end;
- return(returnVal);
- end;
-
- #########################################################################
- # IsScriptInstalled( pTheScript )
- #========================================================================
- # Author: KTA
- # Description: Returns a boolean which indicates whether the input parameter
- # <pTheScript> is installed.
- # Parameters: pTheScript - language identifier for script
- # US - U.S.
- # JP - Japanese
- # SC - Simplified Chinese
- # TC - Traditional Chinese
- # KH - Korean
- # AB - Arabic
- # HB - Hebrew
- # TH - Thai
- # Returns: 1 - if script is installed
- # 0 - if script is not installed
- # Example: IsScriptInstalled('US');
- #========================================================================
- # History:
- # KTA 11/03/93 Created
- # ML 11/29/94 Added Exception Handling support
- # MDF 04/30/96 Changed to check all menu items in the list, as per Intl
- # reqs.
- #########################################################################
- TASK IsScriptInstalled(pTheScript:= '')
- begin
- returnVal := 0; # Init returnVal
- theStringList := StringsToSelectScript(pTheScript);
- if(theStringList)
- begin
- numOfItems := card(theStringList);
- for i := 1 to numOfItems # since there is no "break" command, I can't use "for each"...
- begin
- KeyBoardMenuOrd := WhichMenuIsKeyBoardMenu();
- if(KeyBoardMenuOrd)
- begin
- if(_matchBoolean ([menuItem t:theStringList[i] m:[menu o:KeyBoardMenuOrd]]))
- begin
- returnVal := 1;
- i := numOfItems; # break for loop.
- end;
- end;
- else
- begin
- if(_matchBoolean ([menuItem t:theStringList[i]]))
- begin
- returnVal := 1;
- i := numOfItems; # break for loop.
- end;
- end;
- end;
- end;
- else
- returnVal := 0;
- return(returnVal);
- end;
-
-
- #########################################################################
- # BuildListFromResourceINTL( idNum )
- #========================================================================
- # Author: KTA
- # Description: Returns a list generated from all of the strings in a specified
- # string list resource specified by <idNum>.
- # Parameters: idNum := resource id number for the string list resource.
- # Returns: list - all strings in specified string list resource.
- # Examples: BuildListFromResource( 1000 );
- # Assumptions: This task must be contained within the same file that contains
- # the resources. Currently this task only supports up to 100 strings
- # in a single str# resource.
- # Note: A duplicate of this task exists in 'Globals.Lib'. The reason
- # for this is that Vu has a limitation in the way it handles
- # resources in that it requires that a full path to the file be
- # provided or the resources exist in the current file. Since we
- # do not have access to a fullpath, and do not want to require
- # all users to name their hard drives and folders the same, we
- # opted to place a duplicate copy of this task in all files that
- # want to use it. The naming convesion is to append the name
- # of the application under test to the end of the task name.
- # For example, BuildListFromResourceMacDraw()
- #========================================================================
- # History:
- #
- #########################################################################
- task BuildListFromResourceINTL(idNum)
- begin
- numtimes := 100; #Assumes no resource will contain more than 100 strings
- theList := {};
- for i := 1 to numtimes
- begin
- CurrentFont := GetIndString(idNum,i);
- #Println "This is the currentFont - ", currentFont;
- if (isUndefined(CurrentFont))
- numtimes := i;
- else
- theList := Insert(CurrentFont,Card(theList)+1, theList);
- end;
- #println "This is theList - ", theList;
- return(theList);
- end;
-
-
- #########################################################################
- # SwitchScript( pTheScript )
- #========================================================================
- # Author: KTA
- # Description: Selects the specified script from the KeyBoard Menu
- # Parameters: pTheScript - language identifier for script
- # US - U.S.
- # JP - Japanese
- # SC - Simplified Chinese
- # TC - Traditional Chinese
- # KH - Korean
- # AB - Arabic
- # HB - Hebrew
- # TH - Thai
- # Returns: 1 - if script is switched to
- # 0 - if script is not switched to
- # Example: SwitchScript('US');
- #========================================================================
- # History:
- # KTA 11/03/93 Created
- # KTA 3/21/94 Added support for Language Kits where Keyboard menu cannot
- # be dropped when modal dialogs are present.
- # ML 11/29/94 Added Exception Handling support
- # MDF 04/30/96 Changed to check all menu items in the list, as per Intl
- # reqs.
- #########################################################################
- TASK SwitchScript(pWhichScript := '')
- begin
- returnVal := 0;
- if(IsScriptInstalled(pWhichScript))
- begin
- theStringList := StringsToSelectScript(pWhichScript);
- numOfItems := card(theStringList);
- theMenu := WhichMenuIsKeyBoardMenu();
- for i := 1 to numOfItems
- begin
- theScript := theStringList[i];
- if(theMenu)
- begin
- theItem := _match([menuitem t:theScript m:[menu o:theMenu]]);
- if (theItem)
- i := numOfItems;
- end;
- else
- begin
- try theItem := match[menuitem t:theScript m:[menu o:?theMenu]];
- catch theError
- ExceptionDispatcher(theError);
- if (theItem)
- i := numOfItems;
- end;
- end;
-
- if(theItem)
- begin
- if(theItem.e)
- begin
- _select (theItem);
- LogStr("Selected the '{theScript}' menuItem");
- if (CurrentlySelectedScript() = pWhichScript)
- returnVal := 1;
- else
- begin
- if(pWhichScript = 'US')
- begin
- _PressKey ({CommandKey}); # Command-RightArrow will to the 'US' script system
- _Type ({RightArrowKey});
- _releaseKey ({CommandKey});
- LogStr("Typed 'Command-RightArrow' to go to the 'US' script system");
- if (CurrentlySelectedScript() = pWhichScript)
- returnVal := 1;
- end;
- else
- begin
- numtimes := 10; # arbitrarily chose 10 as loop counter as we currently only support 8 languages
- for i := 1 to numtimes
- begin
- KeyEq(' '); # Command-Space will move to the next script system
- if (CurrentlySelectedScript() = pWhichScript)
- begin
- returnVal := 1;
- i := numtimes;
- end;
- end;
- end;
- end;
- end;
- end;
- end;
- if(returnVal)
- LogStr("Switched to the '{pWhichScript}' script");
-
- return(returnVal);
- end;
-
- #########################################################################
- # SwitchScriptTo(pTheScript)
- #========================================================================
- # Author: MF
- # Description: Selects the specified script from the KeyBoard Menu
- # Parameters: None
- # Returns: what SwitchScript returns
- # Example: SwitchScriptTo('JP');
- #========================================================================
- # History:
- # MDF 04/30/96 Created. This is a more general purpose task than
- # SwitchScriptToUS(), as per Intl request.
- #########################################################################
- task SwitchScriptTo(pTheScript := 'US')
- begin
- global gtheCurrentScript := CurrentlySelectedScript();
- if not(gtheCurrentScript = pTheScript)
- return(SwitchScript(pTheScript));
- end;
-
- #########################################################################
- # SwitchScriptToUS()
- #========================================================================
- # Author: KTA
- # Description: Selects the US script from the KeyBoard Menu
- # Parameters: None
- # Returns: what SwitchScript returns
- # Example: SwitchScriptToUS();
- #========================================================================
- # History:
- # KTA 11/03/93 Created
- # MDF 04/30/96 Now checks gtheCurrentScript in the conditional, instead
- # of calling CurrentlySelectScript().
- #########################################################################
- task SwitchScriptToUS()
- begin
- global gtheCurrentScript := CurrentlySelectedScript();
- if not(gtheCurrentScript = 'US')
- return(SwitchScript('US'));
- end;
-
- #########################################################################
- # SwitchScriptBackToOrig()
- #========================================================================
- # Author: KTA
- # Description: Selects the script specified by the global <gtheCurrentScript>
- # from the KeyBoard Menu
- # Parameters: None
- # Returns: what SwitchScript returns
- # Example: SwitchScriptBackToOrig();
- #========================================================================
- # History:
- # KTA 11/03/93 Created
- #########################################################################
- task SwitchScriptBackToOrig()
- begin
- returnVal := 0;
- if(global gtheCurrentScript)
- begin
- if not (CurrentlySelectedScript() = gtheCurrentScript)
- returnVal := SwitchScript(gtheCurrentScript);
- gtheCurrentScript := 0;
- end;
- return(returnVal);
- end;
-
- #########################################################################
- # WhatResourceBase(pLanguageIdentifier)
- #========================================================================
- # Author: KTA
- # Description: Returns a Resource base number for a given language identifier
- # Parameters: pLanguageIdentifier :=
- # US - US
- # JP - Japanese
- # SC - Simplified Chinese
- # TC - Traditional Chinese
- # KH - Korean
- # AB - Arabic
- # HB - Hebrew
- # TH - Thai
- #
- # Returns: Integer which is the base resource for that particular language
- # Example: mybaseRes := WhatResourceBase('AB');
- #
- #========================================================================
- # History:
- # KTA 11/10/93 Created
- #########################################################################
- TASK WhatResourceBase(pLanguageIdentifier := '')
- begin
- if(pLanguageIdentifier = 'US') # US - 200-299
- returnVal := 200;
- else if(pLanguageIdentifier = 'JP') # Japanese - 300-399
- returnVal := 300;
- else if(pLanguageIdentifier = 'SC') # Simplified Chinese - 400-499
- returnVal := 400;
- else if(pLanguageIdentifier = 'TC') # Traditional Chinese - 500-599
- returnVal := 500;
- else if(pLanguageIdentifier = 'KH') # Korean - 600-699
- returnVal := 600;
- else if(pLanguageIdentifier = 'AB') # Arabic - 700-799
- returnVal := 700;
- else if(pLanguageIdentifier = 'HB') # Hebrew - 800-899
- returnVal := 800;
- else if(pLanguageIdentifier = 'TH') # Thai - 900-999
- returnVal := 900;
-
- return(returnVal);
- end;
-
-
- #########################################################################
- # TypeEnglishText()
- #========================================================================
- # Author: KTA
- # Description: Switches to the U.S. script system, type a line of english text
- # and switches back to the original script.
- # Parameters: none
- # Returns: nothing
- # Example: TypeEnglishText();
- #
- #========================================================================
- # History:
- # KTA 11/11/93 Created
- # ML 11/29/94 Added Exception Handling support
- # MDF 04/30/96 Removed SwitchScriptBackToOrig() as there is not need to
- # switch back to the original script.
- #########################################################################
- TASK TypeEnglishText()
- begin
- SwitchScriptToUS();
- USBaseResource := WhatResourceBase('US');
- theTextStr := GetIndString(USBaseResource+2,1); # Get english text
-
- _type ({theTextStr});
- println "Typed '{theTextStr}'";
- end;
-
- #########################################################################
- # GenerateStandardFontRecord()
- #========================================================================
- # Author: KTA
- # Description: Generates a font record based on the first element of gFontList,
- # the first element of gFontSizeList and the first two elements of
- # gFontStyleList.
- # Parameters: none
- # Returns: theFontRecord - the font record that is generated
- # Example: myfontRecord := GenerateStandardFontRecord();
- #
- #========================================================================
- # History:
- # KTA 11/11/93 Created
- #########################################################################
- Task GenerateStandardFontRecord()
- begin
- global gFontStyleList, gFontSizeList, gFontList;
- theFontRecord := {gFontList[1],gFontSizeList[1],{gFontStyleList[1], gFontStyleList[2]}};
- return(theFontRecord);
- end;
-
-
- #########################################################################
- # HandleDoubleByteStrings(pTestMethod, pNumTimes)
- #========================================================================
- # Author: KTA
- # Description: Defines an override task for typeStr if the current script system
- # uses double byte characters. The side effect of this task is
- # that the global gTypeStrOverRide will be defined and all calls to TypeStr()
- # will be redirected to call the task that has been defined for a specific
- # script system. To remove the effects of this call it is possible to '
- # redefine gTypeStrOverRide as follows:
- # global gTypeStrOverRide := 0;
- # Parameters: none
- # Returns: currScript - language identifier of the currently selected script
- # Example: HandleDoubleByteStrings();
- #========================================================================
- # History:
- # KTA 1/11/94 Created
- # KTA 1/11/94 Insure that the primary script is the primary script
- # MDF 04/30/96 Added Korean string support, and changed to override
- # if fontAndTextLanguage is not 'US', as per Intl reqs.
- #########################################################################
- TASK HandleDoubleByteStrings(pTestMethod, pNumTimes)
- begin
- global gLanguageSettings;
-
- currScript := CurrentlySelectedScript();
- fontAndTextLanguage := gLanguageSettings[3];
-
- # Insure that the current script is the fontAndTextLanguage script
- if(currScript <> fontAndTextLanguage)
- begin
- SwitchScript(fontAndTextLanguage);
- currScript := CurrentlySelectedScript(); # Get the real current script to make sure
- end;
-
- if(currScript = 'JP')
- global gTypeStrOverRide := task TypeJapaneseString;
- if(currScript = 'KH')
- global gTypeStrOverRide := task TypeKoreanString;
- if(currScript = 'SC')
- global gTypeStrOverRide := task TypeSimplifiedChineseString;
- if(currScript = 'TC')
- global gTypeStrOverRide := task TypeTradChineseString;
- return(currScript);
- end;
-
- #########################################################################
- # TypeJapaneseString()
- #========================================================================
- # Author: KTA
- # Description: Types a predefined string that will generate a Japanese string when
- # typed into the bottom line input window.
- # Parameters: pdumpedStr - When overriding TypeStr() the string that was
- # to be typed is passed to the Overriding task. It
- # is ignored in this task.
- # pJapaneseString - a string of characters that will produce a Japanese
- # string when typed into the bottom line input window.
- # Returns: nothing
- # Example: TypeJapaneseString();
- #========================================================================
- # History:
- # KTA 1/11/94 Created
- # ML 11/29/94 Added Exception Handling support
- # MDF 04/30/96 Changed input method for Hiragana and added appropriate
- # script switching, as per Intl request.
- #########################################################################
- TASK TypeJapaneseString(pdumpedStr := '', pJapaneseString := 'jikangaarebategamiwokudasarebaiitoomoimasu. ')
- begin
- SwitchScriptTo('JP');
-
- ##Press Option+Shift+Z to set input method to Hiragana
- _presskey ({OptionKey, Shiftkey});
- _type ({'z'});
- _releaseKey ({OptionKey, Shiftkey});
-
- _type ({pJapaneseString, returnkey});
- LogStr("Typed '{pJapaneseString}' and the return key");
-
- SwitchScriptTo('US');
- end;
-
- #########################################################################
- # TypeKoreanString()
- #========================================================================
- # Author: KTA
- # Description: Types a predefined string that will generate a Korean string when
- # typed into the bottom line input window.
- # Parameters: pdumpedStr - When overriding TypeStr() the string that was
- # to be typed is passed to the Overriding task. It
- # is ignored in this task.
- # TypeKoreanString - a string of characters that will produce a Korean
- # string when typed into the bottom line input window.
- # Returns: nothing
- # Example: TypeKoreanString();
- #========================================================================
- # History:
- # MDF 04/30/96 Added task as per Intl request.
- #########################################################################
- TASK TypeKoreanString(pdumpedStr := '', pKoreanString := 'gksksladms ekdtlsdmf tkfkdgktlqslek.')
- begin
- SwitchScriptTo('KH');
-
- _type ({pKoreanString, returnkey}); # hit return, just in case of there is a floating input window.
- LogStr("Typed '{pKoreanString}' and the return key");
-
- SwitchScriptTo('US');
- end;
-
- #########################################################################
- # TypeSimplifiedChineseString()
- #========================================================================
- # Author: KTA
- # Description: First option-shift-'c' will be typed to set the input method to
- # Pinyin. Then, types a predefined string that will generate a
- # SChinese string when typed into the bottom line input window.
- # Parameters: pdumpedStr - When overriding TypeStr() the string that was
- # to be typed is passed to the Overriding task. It
- # is ignored in this task.
- # pSChineseString - a string of characters that will produce a
- # SChinese string when typed into the bottom
- # line input window.
- # Returns: nothing
- # Example: TypeSimplifiedChineseString();
- #========================================================================
- # History:
- # KTA 1/11/94 Created
- # ML 11/29/94 Added Exception Handling support
- # MDF 04/30/96 Added appropriate script switch and changed the sample
- # key strokes.
- #########################################################################
- TASK TypeSimplifiedChineseString(pdumpedStr := '', pSChineseString := {'pin9', 'guo4', 'dian9', 'nao2', 'gong8', 'si8'})
- begin
- SwitchScriptTo('SC');
-
- ##Press Option+Shift+C to set input method to Pinyin
- _presskey ({OptionKey, Shiftkey});
- _type ({'c'});
- _releaseKey ({OptionKey, Shiftkey});
-
- for each chineseChar in pSChineseString
- begin
- _type ({chineseChar});
- LogStr("Typed '{chineseChar}'");
- end;
- _type ({returnkey}); # hit return, just in case of there is a floating input window.
- LogStr("Typed the return key");
-
- SwitchScriptTo('US');
- end;
-
- #########################################################################
- # TypeTradChineseString()
- #========================================================================
- # Author: KTA
- # Description: First the menuitem for Traditional Chises will be selected.
- # Then, option-shift-'c' will be typed to set the input method to Pinyin
- # Finally, Types a predefined string that will generate a TChinese string when
- # typed into the bottom line input window.
- # Parameters: pdumpedStr - When overriding TypeStr() the string that was
- # to be typed is passed to the Overriding task. It
- # is ignored in this task.
- # pTradChineseSting - a string of characters that will produce a TChinese
- # string when typed into the bottom line input window.
- # Returns: nothing
- # Example: TypeTradChineseString();
- #========================================================================
- # History:
- # KTA 1/11/94 Created
- # ML 11/29/94 Added Exception Handling support
- # MDF 04/30/96 Added appropriate script switch, added return key at end
- # of the string, and removed SelectMenuItem('¡c≈ȧ§§Â') since
- # input method name was modified in StringsToSelectScript(),
- # as per Intl request.
- #########################################################################
- TASK TypeTradChineseString(pdumpedStr := '', pTradChineseSting := {'wo 1','men 1','shi 1','zhong 1','guo 1','ren 1','ta 1','men 1','shi 1','ben 1','di 1','ren 1'})
- begin
- SwitchScriptTo('TC');
-
- ##Press Option+Shift+C to set input method to Pinyin
- _presskey ({OptionKey, Shiftkey});
- _type ({'c'});
- _releaseKey ({OptionKey, Shiftkey});
-
- for each chineseChar in pTradChineseSting
- begin
- _type ({chineseChar});
- LogStr("Typed {chineseChar}");
- end;
- _type ({returnkey}); # hit return, just in case of there is a floating input window.
- LogStr("Typed the return key");
-
- SwitchScriptTo('US');
- end;
-
-
- #########################################################################
- # RemoveTypeStrOverRide(pTestMethod, pNumTimes)
- #========================================================================
- # Author: KTA
- # Description: Removes whatever task reference that has been defined for
- # gTypeStrOverRide.
- # Parameters: none
- # Returns: nothing
- # Example: RemoveTypeStrOverRide();
- #========================================================================
- # History:
- # KTA 1/11/94 Created
- # MDF 04/24/96 Added parameters to the task to support calls from task
- # reference, i.e., call(gClearDoText, pTestMethod, pNumTimes).
- #########################################################################
- TASK RemoveTypeStrOverRide(pTestMethod, pNumTimes)
- begin
- global gTypeStrOverRide := 0;
- end; # RemoveTypeStrOverRide
-
- #########################################################################
- # BuildListFromResource(idNum, pFileName := "")
- #========================================================================
- # Author: KTA
- # Description: Returns a list generated from all of the strings in a specified
- # string list resource specified by <idNum> from the file specified
- # by pFileName.
- # Parameters: idNum := resource id number for the string list resource.
- # pFileName - full path name of file where string resource is located.
- # Returns: list - all strings in specified string list resource.
- # Examples: BuildListFromResource( 1000, FileOfTask() );
- # Note: If string resource is located in script which you're calling
- # this task from, use FileOfTask() to pass in full path
- # filename as per the above example.
- #========================================================================
- # History:
- #
- #########################################################################
- task BuildListFromResource(idNum, pFileName := "")
- begin
- theList := {};
- CurrentItem := 0; # Init
- i := 0;
-
- # To handle lists as returned by FileOfTask()
- if(typeof(pFileName) = 'list')
- pFileName := pFileName[1]+pFileName[2];
-
- if(pFileName)
- begin
- while not(IsUndefined(CurrentItem))
- begin
- i := i +1;
- CurrentItem := GetIndString(idNum,i, pFileName);
- if(CurrentItem)
- theList[Card(theList)+1] := CurrentItem;
- end;
- end;
- else
- begin
- while not(IsUndefined(CurrentItem))
- begin
- i := i +1;
- CurrentItem := GetIndString(idNum,i);
- if(CurrentItem)
- theList[Card(theList)+1] := CurrentItem;
- end;
- end;
- return(theList);
- end;
-